﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WenSkin.Controls;

namespace WenSkinTest.UserControlAll
{
    public partial class UserControlTemplate : WenSkin.Controls.WenUserControl
    {
        public UserControlTemplate()
        {
            InitializeComponent();
        }

        private void wenButton1_Click(object sender, EventArgs e)
        {
            wenListBoxControl1.Items.Add(null);
            wenListBoxControl1.Template = typeof(WenGroupBox);
            wenListBoxControl1.Items.Add(new WenListBoxControl.WenListBoxControlItem());
            wenListBoxControl1.Items.Add("测试");
            wenListBoxControl1.Template = typeof(WenButton);
            wenListBoxControl1.Items.Add("测试按钮模板");
        }

        private void wenButton2_Click(object sender, EventArgs e)
        {
            wenListBoxControl1.Items.RemoveAt(3);
        }

        private void wenButton3_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("A");
            dt.Columns.Add("B");
            dt.Columns.Add("C");

            dt.Rows.Add("001", "001", "");
            dt.Rows.Add("002", "002", "001");
            dt.Rows.Add("003", "003", "001");
            dt.Rows.Add("004", "004", "");
            dt.Rows.Add("005", "005", "");
            dt.Rows.Add("006", "006", "005");
            dt.Rows.Add("007", "007", "006");
            dt.Rows.Add("008", "008", "006");
            for (int i = 0; i < 100; i++)
            {
                dt.Rows.Add(i.ToString(), "008", "006");
            }
            wenListBoxControl1.DataSource = dt;
        }

        private void wenButton4_Click(object sender, EventArgs e)
        {
            propertyGrid1.SelectedObject = wenListBoxControl1;
        }

        private void wenListBoxControl1_ButtonClick(object sender, WenListBoxControl.ButtonClickEventArgs e)
        {
            this.MsgBoxAsterisk("自定义按钮");
        }

        private void wenListBoxControl1_RemoveClick(object sender, WenListBoxControl.ButtonClickEventArgs e)
        {
            this.MsgBoxAsterisk("删除按钮");
        }

        private void wenButton5_Click(object sender, EventArgs e)
        {
            var s = wenListBoxControl1.Items["123"];
            if (s != null)
                MsgBoxAsterisk(s.Text);
        }

        private void wenButton6_Click(object sender, EventArgs e)
        {
            propertyGrid1.SelectedObject = wenDataGridView1;
        }
    }
}
